Skip to main content

NodeController

The NodeController manages SWMM network nodes (junctions, outfalls, storage units, etc.) and provides access to node data, attributes, and simulation results.

Overview​

This controller handles all node-related operations including retrieving node definitions, time series data, and simulation results. It integrates with Azure storage services to provide comprehensive node information for the SWMM network model.

Data Sources​

  • Azure Blob Storage:
    • networkmodel container for node definitions
    • swmm-output container for simulation results
  • Azure Table Storage:
    • Runs table for run metadata
    • NodeOutput table for node time series data
  • Configuration: appsettings.json for connection string

Endpoints​

GET /api/node/nodes​

Retrieves all network nodes with their properties and geographic coordinates.

Response:

  • 200 OK: Returns JSON string containing node definitions
  • 500 Internal Server Error: Storage or processing error

Data Flow:

Node Data Structure:

[
["index", "index", "NodeType", "longitude", "latitude"],
["0", "0", "JUNCTION", "-87.6298", "41.8781"],
["1", "1", "OUTFALL", "-87.6299", "41.8782"]
]

Node Array Format:

  • Index 0: Node index
  • Index 1: Node index (duplicate)
  • Index 2: Node type (JUNCTION, OUTFALL, STORAGE, DIVIDER)
  • Index 3: Longitude
  • Index 4: Latitude

GET /api/node/values​

Retrieves time series data for a specific node attribute.

Query Parameters:

  • index (string): Node index
  • runDateTime (string): Simulation run datetime
  • measurementIndex (string): Attribute type (depth, flow, etc.)
  • scenario (string): Scenario name

Response:

  • 200 OK: Returns time series as JSON array [[timestamp, value], ...]
  • 404 Not Found: Node or run not found
  • 500 Internal Server Error: Processing error

Data Flow:

Time Series Processing:

  • Converts simulation time steps to Unix timestamps (milliseconds)
  • Uses reporting time step from run configuration
  • Handles timezone conversions
  • Returns array of [timestamp, value] pairs

GET /api/node/results​

Retrieves simulation results for a specific node at a given timestep.

Query Parameters:

  • step (string): Simulation timestep
  • runDateTime (string): Simulation run datetime
  • nodeIndex (string): Node index

Response:

  • 200 OK: Returns SwmmNodeResult object
  • 404 Not Found: Results not found
  • 500 Internal Server Error: Processing error

Data Flow:

Azure Storage Details​

Blob Containers​

  • networkmodel: Contains node definitions
  • swmm-output: Contains simulation results by timestep

Table Storage​

  • Runs: Run metadata and parameters
  • NodeOutput: Node time series data
  • Errors: Error logging

Blob Structure​

networkmodel/
├── {partitionKey}/
│ └── nodes

swmm-output/
├── {partitionKey}_{scenario}_{datetime}/
│ ├── {step}
│ └── ...

Data Models​

Node Definition​

public class NodeDefinition
{
public string Index { get; set; }
public string Type { get; set; }
public double Longitude { get; set; }
public double Latitude { get; set; }
}

Node Result​

public class SwmmNodeResult
{
public double Depth { get; set; }
public double Head { get; set; }
public double Inflow { get; set; }
public double Overflow { get; set; }
public double Quality { get; set; }
}

Time Series Point​

public class TimeSeriesPoint
{
public long Timestamp { get; set; } // Unix milliseconds
public double? Value { get; set; }
}

Configuration​

Required Settings:

{
"Values": {
"CloudStorageConnectionString": "DefaultEndpointsProtocol=https;AccountName=...;AccountKey=...;EndpointSuffix=core.windows.net"
}
}

Error Handling​

  • Storage Errors: Logged to Azure Table Storage
  • Missing Data: Returns null or empty arrays
  • Invalid Parameters: Graceful parameter validation
  • Time Processing: Handles timezone and format issues

Performance Considerations​

  • Memory Management: Uses memory streams for blob operations
  • Data Parsing: Efficient string parsing for large datasets
  • Caching: No built-in caching (consider for frequently accessed data)
  • Time Conversion: Optimized timestamp calculations

Dependencies​

  • Azure.Storage.Blobs
  • Azure.Data.Tables
  • GqcStorage1 (Storage utilities)
  • SwmmUtilities (Time series processing)
  • SwmmModels (Data models)

Common Node Types​

  • JUNCTION: Standard junction node
  • OUTFALL: Outfall/discharge point
  • STORAGE: Storage unit/basin
  • DIVIDER: Flow divider

Time Series Processing​

  • Unix Timestamps: Converts to milliseconds since epoch
  • Time Steps: Uses reporting time step from run configuration
  • Time Windows: Supports start/end time filtering
  • Data Validation: Handles null/missing values

Common Node Attributes​

  • Depth: Water depth at node
  • Head: Hydraulic head
  • Inflow: Total inflow to node
  • Overflow: Overflow from node
  • Quality: Water quality parameters

Usage Examples​

Get All Nodes:

GET /api/node/nodes

Get Node Time Series:

GET /api/node/values?index=0&runDateTime=2023-11-16T00:00:00-05:00&measurementIndex=0&scenario=scenario0

Get Node Results:

GET /api/node/results?step=15&runDateTime=2023-11-16T00:00:00-05:00&nodeIndex=0